package com.zijiebutiao.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zijiebutiao.mapper.SetmealMapper;
import com.zijiebutiao.pojos.Setmeal;
import com.zijiebutiao.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class SetmealServiceImpl extends ServiceImpl<SetmealMapper, Setmeal> implements SetmealService {
    @Autowired
    private  SetmealMapper setmealMapper;
    @Transactional(rollbackFor =Exception.class)
    @Override
    public int saveSetmeal(Setmeal setmeal, String... checkgroupIds) {
        setmealMapper.insert(setmeal);
        for (String checkgroupId:checkgroupIds){
            setmealMapper.insertSetmealAndCheckgroup(setmeal.getId(), Integer.valueOf(checkgroupId));
        }
        return 1;
    }

    @Override
    public int editSetmeal(Setmeal setmeal) {
        boolean res = updateById(setmeal);
        return res ? 1:0;
    }
//
//    @Override
//    public int removeSetmeal(Setmeal setmeal) {
//        boolean res=removeById(setmeal);
//        return res ? 1:0;
//    }
}
